package pers.csw.lookBook.controller.front;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import pers.csw.lookBook.common.Res;
import pers.csw.lookBook.dto.BookTagDto;
import pers.csw.lookBook.entity.Books;
import pers.csw.lookBook.service.BookService;

import java.util.ArrayList;
import java.util.List;

@CrossOrigin
@RequestMapping("/books")
@RestController
public class BooksController {
    @Autowired
    BookService bookService;

    @GetMapping("getBookByCategoryId/{categoryId}")
    public Res getBookByCategoryId(@PathVariable Integer categoryId){
        List<BookTagDto> bookByCategoryId = bookService.getBookByCategoryId(categoryId);
        return Res.success(bookByCategoryId);
    }
    @GetMapping("/getBookById/{id}")
    public Res getBookById(@PathVariable Integer id){
        return Res.success(bookService.getById(id));
    }

    @GetMapping("/getMan")
    public Res getMan(){
        return Res.success(bookService.getMan());
    }

    @GetMapping("/getWoMan")
    public Res getWoMan(){
        return Res.success(bookService.getWoMan());
    }

    @GetMapping("/search/{title}")
    public Res searchBook(@PathVariable String title){
        return Res.success(bookService.searchBook(title));
    }
}
